import { userLogin } from '@/api/user'
import { getToken, setToken } from '@/utils/storage.js'
export default {

  namespaced: true,
  state: {
    // 从state中获取token
    token: getToken()
  },
  getters: {},
  mutations: {
    updateToken (state, payload) {
      state.token = payload

      setToken(payload)
    }
  },
  actions: {
    async getToken (context, payload) {
      const data = await userLogin(payload)
      console.log(data)
      context.commit('updateToken', data.data.token)
    }
  }
}
